<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
    <title th:text="${share.title}">Title</title>
    <script th:src="@{/static/ckeditor/ckeditor.js}"></script>
</head>
<body>
<div th:replace="header :: nav"></div>

<script>
    function deleteShare(shareId) {
        var token = $("meta[name='_csrf']").attr("content");
        var header = $("meta[name='_csrf_header']").attr("content");
        var vote = {
            "shareId": shareId,
        }
        $.ajax({
            url: "/deleteShare",
            type:"POST",
            beforeSend: function(request) {
                request.setRequestHeader(header, token);
            },
            timeout:5000,
            data: vote,
            success: function (result) {
                window.location.href = "/index.html?size=5&sort=publishTime,desc"
            },
            error:function (err) {
                alert("网络错误！"+err.toString());
            }
        });
    }
</script>
<div class="container">
    <div class="form-horizontal">
        <div class="form-group text-center">
            <h2 th:text="${share.title}"></h2>
        </div>
        <div class="form-group"  style="border-style:groove;">
            <div rows="10" cols="80" th:utext="${share.content}" style="padding: 40px;">
                完整代码请放到github上
            </div>
            <script>
                // Replace the <textarea id="editor1"> with a CKEditor
                // instance, using default configuration.
            </script>
        </div>
        <hr>
        <div class="form-group" th:if="${canDelete}">
            <a href="#" th:onclick="'deleteShare(\''+${share.id}+'\')'" class="list-group-item active text-center">删除</a>
        </div>
    </div>


</div>
</body>
</html>